﻿
function do_js_beautify() {
    document.getElementById('btn_format').disabled = true;
    js_source = document.getElementById('txt_inputText').value.replace(/^\s+/, '');
    tabsize = document.getElementById('tabsize').value;
    tabchar = ' ';
    if (tabsize == 1) {
        tabchar = '\t';
    }
    if (js_source && js_source.charAt(0) === '<') {
        document.getElementById('txt_outPuttext').value = style_html(js_source, tabsize, tabchar, 80);
    } else {
        document.getElementById('txt_outPuttext').value = js_beautify(js_source, tabsize, tabchar);
    }
    document.getElementById('btn_format').disabled = false;
    return false;
}

function pack_js() {
    var input = document.getElementById('txt_inputText').value;
    var packer = new Packer;
    var bBase62 = document.getElementById("chk_base62").value;
    var bShrink = document.getElementById("chk_shrink").value;
    var output = packer.pack(input, bBase62 ? 1 : 0, bShrink ? 1 : 0);
    document.getElementById('txt_outPuttext').value = output;
}
